// var $parentNode = window.parent.document;

// function $childNode(name) {
//     return window.frames[name]
// }

// // tooltips
// $('.tooltip-demo').tooltip({
//     selector: "[data-toggle=tooltip]",
//     container: "body"
// });

// // 使用animation.css修改Bootstrap Modal
// $('.modal').appendTo("body");

// $("[data-toggle=popover]").popover();


//判断当前页面是否在iframe中
if (top == this) {
    var gohome = '<div class="gohome"><a class="animated bounceInUp" href="index.html?v=4.0" title="返回首页"><i class="fa fa-home"></i></a></div>';
    $('body').append(gohome);
}

//animation.css
function animationHover(element, animation) {
    element = $(element);
    element.hover(
        function () {
            element.addClass('animated ' + animation);
        },
        function () {
            //动画完成之前移除class
            window.setTimeout(function () {
                element.removeClass('animated ' + animation);
            }, 2000);
        });
}

//拖动面板
function WinMove() {
    var element = "[class*=col]";
    var handle = ".ibox-title";
    var connect = "[class*=col]";
    $(element).sortable({
            handle: handle,
            connectWith: connect,
            tolerance: 'pointer',
            forcePlaceholderSize: true,
            opacity: 0.8,
        })
        .disableSelection();
};

$("button.btn-submit").click(function () {
    var x = $('form').serializeArray();
    var t="{";
    $.each(x, function(i, field){
        t+="\""+field.name+"\":\""+field.value+"\"";
        if(x.length-1!=i){t+=',';}
    });
    t+="}";
    $.ajax({
        type:"post",
        url:$('form').attr('action'),
        async:true,
        data:JSON.parse(t),
        dataType:"json",
        success:function(result){
            if(result.code == 10000){
                var m = jqueryAlert({
                    'title'   : '成功',
                    'content' : result.msg,
                    'modal'   : true,
                    'animateType' : '',
                    'buttons' :{
                        '确定' : function(){
                           location.href = SCOPE.MAIN_URL;
                        }
                    }
                })
                setTimeout(function () {
                    location.href = SCOPE.MAIN_URL;
                },2000);
            }else{
                var m =jqueryAlert({
                    'title'   : '错误',
                    'content' : result.msg,
                    'modal'   : true,
                    'animateType' : '',
                    'buttons' :{
                        '确定' : function(){
                            m.close();
                        },
                    }
                })
                // location.href = "{:U('Index/index')}"
            }
        }
    });
})

